import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UserPointVO, UserPointForm, UserPointQuery } from '@/api/system/userPoint/types';

/**
 * 查询积分配置列表
 * @param query
 * @returns {*}
 */

export const listUserPoint = (query?: UserPointQuery): AxiosPromise<UserPointVO[]> => {
  return request({
    url: '/system/userPoint/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询积分配置详细
 * @param id
 */
export const getUserPoint = (id: string | number): AxiosPromise<UserPointVO> => {
  return request({
    url: '/system/userPoint/' + id,
    method: 'get'
  });
};

/**
 * 新增积分配置
 * @param data
 */
export const addUserPoint = (data: UserPointForm) => {
  return request({
    url: '/system/userPoint',
    method: 'post',
    data: data
  });
};

/**
 * 修改积分配置
 * @param data
 */
export const updateUserPoint = (data: UserPointForm) => {
  return request({
    url: '/system/userPoint',
    method: 'put',
    data: data
  });
};

/**
 * 删除积分配置
 * @param id
 */
export const delUserPoint = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/userPoint/' + id,
    method: 'delete'
  });
};
